#coding:utf-8

import json

def remove_punctuation(to_translate, translate_to=u''):
    not_letters_or_digits = u'.!"#%\'()*+,-:;<=>?@[\]^_`{|}~“”：！【】·？《》，… ╗╚┐└—。、（）；/’‘'
    translate_table = dict((ord(char), translate_to) for char in not_letters_or_digits)
    return to_translate.translate(translate_table)


def cut(min_count,location1,location2):
    f1 = open(location1,mode='r')
    f2 = open(location2,mode='w')

    for line in f1:
        v,c = json.loads(line)
        if c < min_count:
            continue
        vv = remove_punctuation(v)
        if vv != v:
            continue
        f2.write(line)


    f1.close()
    f2.close()


if __name__ == '__main__':

    print 'Hi'

    location1 = '../measure.txt'
    location2 = '../measure.s.txt'
    min_count = 5

    cut(min_count,location1,location2)


